﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "chatserver.h"
#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow {
  Q_OBJECT

public:
  explicit MainWindow(QWidget *parent = nullptr);
  ~MainWindow();

private slots:
  void on_pb_startListen_clicked();

  void on_pb_stopListen_clicked();

private slots:
  void receiveMsg(const QString &ip, const QString &port,
                  const QByteArray &rawMsg);

private:
  void startListenCtrl();
  void stopListenCtrl();
  void recHexMsgShow(const QString &ip, const QString &port,
                     const QByteArray &rawMsg);
  void recStrMsgShow(const QString &ip, const QString &port,
                     const QByteArray &rawMsg);
  void msgUpdate(QString &strMsg);
  int divToRes(QString &str);
  int allToRes();
  void showNU(QString id, QString realTimeRate, QString cumulativeRate);
  void showHSHYJXT();
  void chatServerReply();

private:
  Ui::MainWindow *ui;

  ChatServer *chatServer;
};

#endif // MAINWINDOW_H
